package com.woniuxy.usercoachassemble.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.woniuxy.usercoachassemble.dao.UserMapper;
import com.woniuxy.usercoachassemble.entity.CoachInfo;
import com.woniuxy.usercoachassemble.entity.User;
import com.woniuxy.usercoachassemble.entity.Userinfo;
import com.woniuxy.usercoachassemble.dao.UserinfoMapper;
import com.woniuxy.usercoachassemble.service.UserinfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 上次登录地址 服务实现类
 * </p>
 *
 * @author Lucas
 * @since 2020-07-09
 */
@Service
public class UserinfoServiceImpl extends ServiceImpl<UserinfoMapper, Userinfo> implements UserinfoService {
//更新学员的基本信息
    @Autowired
    private UserinfoMapper userinfoMapper;

    @Override
    public void updatauserinfobyuserid(Userinfo userinfo){
        UpdateWrapper<Userinfo> wrapper = new UpdateWrapper<>();
        wrapper.eq("user_id",userinfo.getUserId());
        userinfoMapper.update(userinfo,wrapper);

    }
//更新教练的基本信息
@Override
    public void updatecoachuserinfo(Userinfo userinfo, CoachInfo coachInfo){

        UpdateWrapper<Userinfo> wrapper = new UpdateWrapper<>();
        wrapper.eq("user_id",userinfo.getUserId());
        userinfoMapper.update(userinfo,wrapper);
    }

    /**
     * 查看哪些瑜伽馆给我发出邀请
     * @param userId
     */
    @Override
    public List<Map<String,Object>> selectChooseMe(int userId) {

        List<Map<String, Object>> chooseMe = userinfoMapper.selectChooseMe(userId);
        return chooseMe;
    }

}
